The present invention generally relates to computer systems, and, more particularly to the storage of information in a file system.
A xe2x80x9csnapshotxe2x80x9d is essentially a logical copy of the information stored on a volume at a particular instant in time. A snapshot may be used like a backup copy of the volume, but is much faster to create than a full backup. As used herein, a xe2x80x9cbase volumexe2x80x9d is the actual volume of which the snapshot was taken. A snapshot system uses a differential file to track the changes written to the base volume after the snapshot is captured. If multiple snapshots are taken over time, a differential file exists for each snapshot.
To maintain the snapshot data, when a change is written to an allocation unit (e.g., a cluster) that was in use at the time of the snapshot, the original data is copied from the allocation unit to the differential file before writing the new data. This method is often referred to as xe2x80x9ccopy-on-write.xe2x80x9d In this way, the state (i.e., snapshot) of the base volume at the time the snapshot was taken is accessible by reading current data from the base volume in conjunction with any data stored in the differential file associated with the snapshot.
In many computer systems, there may be a desire to maintain the differential file on the base volume, for instance if there is only one volume in the computer system. However, there are problems associated with maintaining the differential file on the base volume.
One problem is that the process of capturing the snapshot may take a relatively significant amount of time. During that time, potentially many writes may occur to the base volume. Suspending writes to the base volume during the time that the snapshot is being captured negatively impacts perceived system performance.
Another problem with maintaining a differential file on the base volume arises after the snapshot has been captured. If a significant number of writes occur to the base volume after the snapshot is created, the differential file may become full. With prior systems, a snapshot became invalid for its intended purpose once the differential file became full and new writes to the base volume could no longer be tracked. Accordingly, a large amount of space needs to be reserved for such differential files so that they remain valid for a long time. However, reserving large amounts of space is extremely wasteful if that space is not subsequently used.
An efficient mechanism for creating a snapshot of a base volume and maintaining a differential file on the base volume has eluded those skilled in the art. Accordingly, a need exists for an improvement to existing snapshot systems to better manage differential files on base volumes.
The present invention provides a system and method for creating a snapshot with a differential file without suspending writes, wherein the differential file is maintained on the base volume and can grow as needed. When notice is received that a snapshot is to be created, existing free space is allocated on the base volume to store the differential file for the snapshot. Writes to the base volume are allowed, except that writes to the free space allocated to the differential file are prevented by the pre-allocation. Then the operations necessary to capture the snapshot are performed. By pre-allocating free space on the base volume, writes to the base volume may continue while ensuring that the differential file is available to track new writes at the instant the snapshot is captured. In this manner, the snapshot system is afforded the time necessary to complete the snapshot process without having to suspend writes to the entire base volume. After the snapshot process is complete, data may be copied to the differential file as writes are received (copy-on-write).
In accordance with another aspect of the invention, a mechanism is provided to allow the differential file to grow beyond its currently allocated space. Over time, the differential file may start becoming full. To safely grow the differential file, additional free space is identified. The present invention selects new free space from the free space currently on the base volume in conjunction with the free space at the time the snapshot was captured. In this manner, the differential file may expand into free space on the base volume that was also free at the instant the snapshot was captured without overwriting allocation units on the base volume that the snapshot needs. Preferably, the free space bitmap file of the snapshot volume is used to identify the free space at the time the snapshot was captured. In this way, the present invention enables a differential file to safely grow as needed.